package cn.tedu.micro.demo.common.controller;

import cn.tedu.micro.demo.common.protocol.JsonResult;
import cn.tedu.micro.demo.common.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/order/")
public class OrderController {
    @Autowired
    private OrderService orderService;
    @PostMapping("submit")
    public JsonResult<Boolean> submuitOrder(Integer userId, String productCode, Integer count) {
        Boolean result = orderService.submitOrder(userId, productCode, count);
        if (result){
//            新增成功
            return JsonResult.ok("下单成功", result);
        }else {

        return JsonResult.ok("下单失败",result);
        }
    }
}
